
# 定义字典
my_dict1 = {'rocky':99,'cx':88,'rockycheng':77}
# 定义空字典
my_dict2 = {}
my_dict3 = dict()
print(f'字典1的内容是：{my_dict1},类型：{type(my_dict1)}')
print(f'字典1的内容是：{my_dict2},类型：{type(my_dict2)}')
print(f'字典1的内容是：{my_dict3},类型：{type(my_dict3)}')

# 定义重复key的字典
my_dict1 = {'rocky' :99 ,'rocky' :88 ,'rockycheng' :77}
print(f'重复key的字典的内容是：{my_dict1}')

# 从字典中基于key获取从value
my_dict1 = {'rocky':99,'cx':88,'rockycheng':77}
score = my_dict1['cx']
print(f'cx的考试分数是：{score}')
score = my_dict1['rocky']
print(f'cx的考试分数是：{score}')

# 定义嵌套字典
stu_score_dict = {
    '王力宏':{
        'chinese':77,
        'math':66,
        'english':33,
    },'周杰伦':{
        'chinese':88,
        'math':86,
        'english':55,
    },'林俊杰':{
        'chinese':99,
        'math':96,
        'english':66,
    }
}
print(f'学生的考试信息是：{stu_score_dict}')

# 从嵌套字典中获取数据
# 看一下周杰伦的语文信息
score = stu_score_dict['周杰伦']['chinese']
print(f'周杰伦的语文成绩是{score}分')
